
#include "thread.h"
#include <iostream>
#include <time.h>
#include <unistd.h>

using namespace std;


void* MiThread::run(void *param) const{

    int *i = new int;
    while(!_terminate){
        (*i)++;
    }

    cout << *i << endl;

    return i;
}

int MiThread::end(){
    int* v = (int*)Thread::end();
    int value = *v;
    delete (int*) v;
    return value;
}


int main(void){

    MiThread th1;
    MiThread th2;

    th1.start(NULL);
    th2.start(NULL);

    usleep(1000*1000); //1 sec.

    int a = th1.end();
    int b = th2.end();

    return 0;
}
